var mongoose = require('mongoose');

//链接数据库
mongoose.connect('mongodb://localhost/test');

var db = mongoose.connection;
//链接失败时
db.on('error', console.error.bind(console, 'connection error:'));

var getDb = function(){
	return mongoose;
};

module.exports = new getDb();